home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Entwickler / WASTE Object Handlers ƒ / Handler Source / WE_PICT_Handler.c < prev    next >
Text File  |  1995-06-05  |  2KB  |  91 lines

  1. // PICT Object Handler for the WASTE Text Engine
  2. // by Michael F. Kamprath, kamprath@earthlink.net
  3. //
  4. // v1.0, 12 March 1995
  5. // v1.1, 5 June 1995,     Added InstallPICTObject() to install the PICT handler
  6. //                        by itself.
  7. //
  8.  
  9. #include "WASTE.h"
  10. #include "WE_PICT_Handler.h"
  11. #include "WASTE_Objects.h"
  12.  
  13. //
  14. // Hanlder UPPs
  15. //
  16.  
  17. static WENewObjectUPP           newPICTUPP = NULL;
  18. static WEDisposeObjectUPP       disposePICTUPP = NULL;
  19. static WEDrawObjectUPP          drawPICTUPP = NULL;
  20.  
  21. //
  22. // InstallPICTObject()
  23. //        Installs the PICT handler into WASTE.
  24. //
  25. OSErr    InstallPICTObject( WEHandle theWE )
  26. {
  27. OSErr    iErr;
  28.  
  29.     if (newPICTUPP == NULL)
  30.     {
  31.         newPICTUPP = NewWENewObjectProc(HandleNewPicture);
  32.         disposePICTUPP = NewWEDisposeObjectProc(HandleDisposePicture);
  33.         drawPICTUPP = NewWEDrawObjectProc(HandleDrawPicture);
  34.     
  35.         iErr = WEInstallObjectHandler(kTypePicture, weNewHandler, (UniversalProcPtr)newPICTUPP, theWE);
  36.         if (iErr) return(iErr);
  37.         iErr = WEInstallObjectHandler(kTypePicture, weDisposeHandler, (UniversalProcPtr)disposePICTUPP, theWE);
  38.         if (iErr) return(iErr);
  39.         iErr = WEInstallObjectHandler(kTypePicture, weDrawHandler, (UniversalProcPtr)drawPICTUPP, theWE);
  40.         if (iErr) return(iErr);
  41.     }
  42.     
  43.     return(noErr);
  44. }
  45.  
  46. //
  47. // New Object Handler for PICTs
  48. //
  49. pascal OSErr    HandleNewPicture(Point *defaultObjectSize,WEObjectReference objectRef)
  50. {
  51. PicHandle    thePic;
  52. Rect        theFrame;
  53.  
  54.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  55.     
  56.     theFrame = (*thePic)->picFrame;
  57.     
  58.     OffsetRect(&theFrame, -theFrame.left, -theFrame.top);
  59.     
  60.     *defaultObjectSize = botRight(theFrame);
  61.         
  62.     return(noErr);
  63. }
  64.  
  65. //
  66. // Dispose Object Handler for PICTS
  67. //
  68. pascal OSErr    HandleDisposePicture(WEObjectReference objectRef )
  69. {
  70. PicHandle    thePic;
  71.  
  72.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  73.     
  74.     if (thePic)
  75.         KillPicture(thePic);
  76.  
  77.     return(MemError());
  78. }
  79. //
  80. // Draw Object Handler for PICTs
  81. //
  82. pascal OSErr    HandleDrawPicture (Rect *destRect, WEObjectReference objectRef )
  83. {
  84. PicHandle    thePic;
  85.     
  86.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  87.  
  88.     DrawPicture(thePic, destRect);
  89.             
  90.     return( noErr );
  91. }